package com.clkj.goldpartner.service.impl;

import com.clkj.goldpartner.dao.*;
import com.clkj.goldpartner.pojo.*;
import com.clkj.goldpartner.service.SystemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author 杨行
 * @date 2021/2/28 16:35
 */
@Service
public class SystemServiceImpl implements SystemService {
    @Autowired
    private MemberMapper memberMapper;

    @Autowired
    private SupplierMapper supplierMapper;

    @Autowired
    private CustomerMapper customerMapper;

    @Autowired
    private WarehouseMapper warehouseMapper;

    @Autowired
    private ShopMapper shopMapper;

    /**
     * 获取门店列表
     *
     * @return
     */
    @Override
    public List<Shop> getShopAndChildren() {
        return shopMapper.getShopAndChildren();
    }

    /**
     * 从账号获取人员
     *
     * @param shop_account
     * @return
     */
    @Override
    public Shop getShopByAccount(String shop_account) {
        return shopMapper.getShopByAccount(shop_account);
    }

    /**
     * 关闭门店
     *
     * @param shop_id
     */
    @Override
    public void updateShop(Integer shop_id) {
        shopMapper.updateShop(shop_id);
    }

    /**
     * 获取门店列表
     *
     * @return
     */
    @Override
    public List<Shop> getShop() {
        return shopMapper.getShop();
    }

    /**
     * 添加门店
     *
     * @param shop
     */
    @Override
    public void addShop(Shop shop) {
        shopMapper.insertSelective(shop);
    }

    /**
     * 获取人员管理列表
     *
     * @param shop_id
     * @param member_name
     * @param member_sex
     * @return List<Member>
     */
    @Override
    public List<Member> getMemberList(Integer shop_id, String member_name, String member_sex) {
        return memberMapper.getMemberList(shop_id, member_name, member_sex);
    }

    /**
     * 获取相关分类人员列表
     *
     * @param shop_id
     * @param member_type
     * @return List<Member>
     */
    @Override
    public List<Member> getMemberListByType(Integer shop_id, String member_type) {
        return memberMapper.getMemberListByType(shop_id, member_type);
    }

    /**
     * 添加人员
     *
     * @param member
     */
    @Override
    public void addMember(Member member) {
        memberMapper.insertSelective(member);
    }

    /**
     * 修改人员
     *
     * @param member
     */
    @Override
    public void editMember(Member member) {
        memberMapper.updateByPrimaryKeySelective(member);
    }

    /**
     * 删除人员
     *
     * @param ids
     */
    @Override
    public void deleteMember(String ids) {
        memberMapper.deleteMember(ids);
    }

    /**
     * 获取最后一位编号
     *
     * @return String
     */
    @Override
    public String getSupplier_num() {
        return supplierMapper.getSupplier_num();
    }

    /**
     * 新增供货商
     *
     * @param supplier
     */
    @Override
    public void addSupplier(Supplier supplier) {
        supplierMapper.insertSelective(supplier);
    }

    /**
     * 修改供货商
     *
     * @param supplier
     */
    @Override
    public void editSupplier(Supplier supplier) {
        supplierMapper.updateByPrimaryKeySelective(supplier);
    }

    /**
     * 获取供货商
     *
     * @param shop_id
     * @param supplier_name
     * @param supplier_num
     * @return List<Supplier>
     */
    @Override
    public List<Supplier> getSupplier(Integer shop_id, String supplier_name, String supplier_num) {
        return supplierMapper.getSupplier(shop_id, supplier_name, supplier_num);
    }

    /**
     * 获取可用供货商
     *
     * @param shop_id
     * @param supplier_name
     * @param supplier_num
     * @return List<Supplier>
     */
    @Override
    public List<Supplier> getSupplierNow(Integer shop_id, String supplier_name, String supplier_num) {
        return supplierMapper.getSupplierNow(shop_id, supplier_name, supplier_num);
    }

    /**
     * 删除供货商
     *
     * @param ids
     */
    @Override
    public void deleteSupplier(String ids) {
        supplierMapper.deleteSupplier(ids);
    }

    /**
     * 获取客户列表
     *
     * @param shop_id
     * @param customer_name
     * @param customer_num
     * @return List<Customer>
     */
    @Override
    public List<Customer> getCustomer(Integer shop_id, String customer_name, String customer_num) {
        return customerMapper.getCustomer(shop_id, customer_name, customer_num);
    }

    /**
     * 获取最后一位编号
     *
     * @return String
     */
    @Override
    public String getCustomer_num() {
        return customerMapper.getCustomer_num();
    }

    /**
     * 添加客户
     *
     * @param customer
     */
    @Override
    public void addCustomer(Customer customer) {
        customerMapper.insertSelective(customer);
    }

    /**
     * 修改客户
     *
     * @param customer
     */
    @Override
    public void editCustomer(Customer customer) {
        customerMapper.updateByPrimaryKeySelective(customer);
    }

    /**
     * 删除客户列表
     *
     * @param ids
     */
    @Override
    public void deleteCustomer(String ids) {
        customerMapper.deleteCustomer(ids);
    }

    /**
     * 添加仓库
     *
     * @param warehouse
     */
    @Override
    public void addWarehouse(Warehouse warehouse) {
        warehouseMapper.insertSelective(warehouse);
    }

    /**
     * 修改仓库
     *
     * @param warehouse
     */
    @Override
    public void editWarehouse(Warehouse warehouse) {
        warehouseMapper.updateByPrimaryKeySelective(warehouse);
    }

    /**
     * 获取仓库列表
     *
     * @param shop_id
     * @param warehouse_name
     * @param warehouse_type
     * @return
     */
    @Override
    public List<Warehouse> getWarehouse(Integer shop_id, String warehouse_name, String warehouse_type) {
        return warehouseMapper.getWarehouse(shop_id, warehouse_name, warehouse_type);
    }

    /**
     * 删除仓库
     *
     * @param ids
     */
    @Override
    public void deleteWarehouse(String ids) {
        warehouseMapper.deleteWarehouse(ids);
    }

    /**
     * 获取过期客户
     *
     * @param shop_id
     * @return
     */
    @Override
    public List<Customer> getCustomerWarn(Integer shop_id) {
        return customerMapper.getCustomerWarn(shop_id);
    }

    /**
     * 获取过期代理商
     *
     * @param shop_id
     * @return
     */
    @Override
    public List<Supplier> getSupplierWarn(Integer shop_id) {
        return supplierMapper.getSupplierWarn(shop_id);
    }

}
